using System;

namespace Wikey.Utilities.Extensions
{
    public static class ReflectionExtensions {
        public static T GetAttributeValue<T>(this object o) where T : class, new() {
            Type valueType = o.GetType();

            var values = valueType.GetCustomAttributes(true);

            foreach (var value in values) {
                if (value.GetType() == typeof(T)) {
                    return value as T;
                }
            }

            return new T();
        }
    }

}